---
title: GCS Content
---

This example shows how to add content from a Google Cloud Storage (GCS) bucket to your knowledge base. This allows you to process documents stored in Google Cloud without downloading them locally.

## Code

```python gcs.py
"""This cookbook shows how to add content from a GCS bucket to the knowledge base.
1. Run: `python cookbook/agent_concepts/knowledge/12_from_gcs.py` to run the cookbook
"""

import asyncio

from agno.agent import Agent
from agno.db.postgres import PostgresDb
from agno.knowledge.knowledge import Knowledge
from agno.knowledge.remote_content.remote_content import GCSContent
from agno.vectordb.pgvector import PgVector

contents_db = PostgresDb(
    db_url="postgresql+psycopg://ai:ai@localhost:5532/ai",
    knowledge_table="knowledge_contents",
)

# Create Knowledge Instance
knowledge = Knowledge(
    name="Basic SDK Knowledge Base",
    description="Agno 2.0 Knowledge Implementation",
    contents_db=contents_db,
    vector_db=PgVector(
        table_name="vectors", db_url="postgresql+psycopg://ai:ai@localhost:5532/ai"
    ),
)

# Add from GCS
asyncio.run(
    knowledge.add_content_async(
        name="GCS PDF",
        remote_content=GCSContent(
            bucket_name="thai-recepies", blob_name="ThaiRecipes.pdf"
        ),
        metadata={"remote_content": "GCS"},
    )
)


agent = Agent(
    name="My Agent",
    description="Agno 2.0 Agent Implementation",
    knowledge=knowledge,
    search_knowledge=True,
    debug_mode=True,
)

agent.print_response(
    "What is the best way to make a Thai curry?",
    markdown=True,
)
```

## Usage

<Steps>
  <Step title="Install libraries">
    ```bash
    pip install -U agno sqlalchemy psycopg pgvector google-cloud-storage
    ```
  </Step>

  <Step title="Configure Google Cloud credentials">
    Set up your GCS credentials using one of these methods:
    - Service Account Key: Set `GOOGLE_APPLICATION_CREDENTIALS` environment variable
    - gcloud CLI: `gcloud auth application-default login`
    - Workload Identity (if running on Google Cloud)
  </Step>

  <Snippet file="run-pgvector-step.mdx" />

  <Step title="Run the example">
    <CodeGroup>
    ```bash Mac
    python cookbook/knowledge/basic_operations/07_from_gcs.py
    ```

    ```bash Windows
    python cookbook/knowledge/basic_operations/07_from_gcs.py
    ```
    </CodeGroup>
  </Step>
</Steps>

## Params

<Snippet file="gcs-remote-content-params.mdx" />